<?php
namespace App\Services\WechatHandler;

/**
 * 文本消息处理器
 * @package App\WechatHandler
 */
class TextMessageHandler extends BaseEventHandler
{
    /**
     * 消息处理
     * @param null $payload
     */
    public function handle($payload = null)
    {
        //消息异步保存到记录表
        \App\Jobs\WxmsgTextHandle::dispatch($this->appid, $payload)->onQueue('low');

        //自动回复
        $autoreplySer = new \App\Services\WxAutoreply\WxAutoreplyService($this->appid);
        $replyData = $autoreplySer->checkHitKeyword($payload['Content'] ?? '');
        if ($replyData){
            return $replyData;
        }

        return '';
    }
}